-
Notifications
You must be signed in to change notification settings - Fork 22
Add optional background thread for JWKS refresh #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
bbockelm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot - please address code review comments and the linter issues.
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
bbockelm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot - please address code review items and linter.
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot - address the linter issues. |
|
@copilot - address linter issues. Run clang-format and ensure there are no problems. |
All files already pass clang-format checks. Verified:
The linter issues were previously fixed in commit 6f3a1de. No additional changes required. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: bbockelm <1093447+bbockelm@users.noreply.github.com>
Co-authored-by: bbockelm <1093447+bbockelm@users.noreply.github.com>
Co-authored-by: bbockelm <1093447+bbockelm@users.noreply.github.com>
…atabase to get issuers - Remove once_flag from BackgroundRefreshManager, allowing multiple start/stop cycles - Move once_flag to Validator class for first-time initialization on verification - Remove issuer tracking (add_issuer, get_issuers, m_issuers map) - Add get_all_issuers_from_db() method to retrieve issuers from SQLite cache - Update refresh_loop to query database instead of tracking issuers - Improve thread safety in start/stop methods with proper mutex handling - Format code with clang-format Co-authored-by: bbockelm <1093447+bbockelm@users.noreply.github.com>
…antics - Include expired entries in get_all_issuers_from_db() for refresh after long downtime - Set next_update to now for expired entries so they get refreshed immediately - Use std::memory_order_acquire/release for all atomic operations instead of sequential consistency - Improves performance while maintaining proper synchronization guarantees Co-authored-by: bbockelm <1093447+bbockelm@users.noreply.github.com>
- Apply clang-format to test/integration_test.cpp - Fix line wrapping and indentation to comply with LLVM style - No functional changes, only formatting adjustments Co-authored-by: bbockelm <1093447+bbockelm@users.noreply.github.com>
- Add background_successful_refreshes and background_failed_refreshes counters to IssuerStats for tracking per-issuer background refresh results - Add is_running() method to BackgroundRefreshManager to check thread state - Track statistics in refresh_loop() when JWKS refresh succeeds or fails - Add maybe_write_monitoring_file_from_verify() that skips file writes when background refresh thread is running (to avoid redundant writes) - Write monitoring file from background thread at end of each refresh cycle - Update get_json() to include new background refresh statistics - Update integration test to verify background refresh via monitoring API using keycache_set_jwks() to force cache entry with short update interval
6f3a1de to
0c973ff
Compare
- Change MonitoringStats::get_json() to cast integer counters to int64_t instead of double for proper integer representation in JSON - Update monitoring_test.cpp to parse integer fields using is<int64_t>() and get<int64_t>() instead of double - Use memory_order_relaxed for atomic loads in get_json() since these are read-only statistics snapshots
|
@copilot - please fix remaining clang-format issues found by the linter. |
- Apply clang-format to fix line wrapping in monitoring statistics code - Adjust formatting for long picojson::value() calls - All files now pass clang-format --Werror check Co-authored-by: bbockelm <1093447+bbockelm@users.noreply.github.com>
Fixed in commit 1b2c830. Applied clang-format to Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Background Thread for JWKS Refresh - Latest Updates
Recent Changes (This Commit)
Linter fixes
src/scitokens_monitoring.cppclang-format --dry-run --WerrorcheckPrevious Changes
Statistics and Monitoring
1. Include expired entries for refresh
get_all_issuers_from_db()now returns expired entries instead of skipping themnext_updateset tonowfor immediate refresh2. Optimized atomic operations
m_shutdownandm_runningatomics in BackgroundRefreshManagerstd::memory_order_acquirestd::memory_order_release3. Thread Management
BackgroundRefreshManagersingleton that supports multiple start/stop cyclesstd::once_flagin Validator)Configuration
keycache.refresh_interval_ms- wake interval N (default: 60s)keycache.refresh_threshold_ms- refresh threshold M (default: 10min)Testing
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.